FOR COUNTER = 0 TO 10 STEP 2 PRINT "Counter:", COUNTER NEXT COUNTER ' END
Counter: 0 Counter: 2 Counter: 4 Counter: 6 Counter: 8 Counter: 10
In this program, the STEP 2
means to count upward "by twos."
Here is the syntax when STEP
is used:
FOR counter = startingValue TO endingValue STEP stepSize loopBody NEXT counter
The list of rules changes just a little:
NEXT
counter shows the end of the loop body.This program follows those rules:
LET C = 0 LET START = 2 LET FINISH = 10 LET SIZE = 2 ' FOR C = START TO FINISH STEP SIZE PRINT C; NEXT C ' END
In this program,
stepSize is the variable SIZE
.
That is OK.
What do you suppose the program prints to the screen (remember that the semicolon keeps all the output on one line)?